package Thread;

/**
 * Created with IntelliJ IDEA.
 * Description: 单例模式之懒汉模式练习
 */
class MySingleTon {
    private static volatile MySingleTon instance;
    private static Object locker = new Object();

    private MySingleTon() {}

    public static MySingleTon getInstance() {
        if(instance == null) {
            synchronized (locker) {
                if(instance == null) {
                    instance = new MySingleTon();
                }
            }
        }
        return instance;
    }
}

public class ThreadDemo32 {
    public static void main(String[] args) {
        MySingleTon singleTon = MySingleTon.getInstance();
    }
}
